package com.weavernorth.util.action;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @ClassName AnnualAction
 * @Description 年假节点后附加操作
 * @Author ys951
 * @Date 2019/10/18 14:29
 * @Version 1.0
 */
public class AnnualAction extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        writeLog("逻辑执行开始");
        // 请求ID
        String requestid = requestInfo.getRequestid();
        // 表单名称
        String tablename = requestInfo.getRequestManager().getBillTableName();

        RecordSet rs = new RecordSet();
        StringBuffer sbf = new StringBuffer();

        String url = "select * from " + tablename + " where requestid =  ?";
        writeLog("url------" + url);
        rs.executeQuery(url, requestid);
        writeLog("requestid------" + requestid);
        rs.next();

        // 申请天数
        String auualDay = rs.getString("applyDays");
        // 人员ID
        String userid = rs.getString("applyPerson");
        sbf.append("update HrmAnnualManagement set annualdays = annualdays - ? where resourceid = ? and annualyear = '2019'");
        rs.executeUpdate(sbf.toString(), auualDay, userid);
        writeLog("逻辑执行结束");

        return SUCCESS;
    }
}
